package com.niiwoo.civet.trade.enums;

/**
 *
 * 还款处理中间状态
 * Created by dell on 2018/4/25.
 */
public enum  RefundProcessMessageEnum {

    PROJECT_SELECT_EXCEPTION("1000","标的查询异常"),
    PROJECT_NOT_FUND("1001","标的不存在"),
    PROJECT_SUMMARY_SELECT_EXCEPTION("1002","标的摘要信息查询异常"),
    PROJECT_SUMMARY_NOT_FUND("1003","标的摘要信息不存在"),

    CALCULATE_TYPE_CHECK_NOT_FUND("1200","获取还款计算逻辑实例异常，请检查借款类型与还款逻辑处理的映射"),
    CALL_CALCULATE_RETURN_NULL("1201","还款计算逻辑成功调用[calaulateAmount]，但返回结果为空 return = null"),
    CALL_CALCULATE_PROCESS_EXCEPTION("1202","还款计算逻辑处理异常，"),

    CALL_CALCULATE_RETUDN_NULL("1214","分账计算逻辑返回的业务明细中CalculateFeeDTO=null"),
    CALL_CALCULATE_RETUDN_NULL_DETAIL("1215","分账计算逻辑返回的业务明细中detail=null"),
    CALL_CALCULATE_RETUDN_NULL_DETAIL_BIZ("1216","分账计算逻辑返回的业务明细中biz=null"),
    CALL_CALCULATE_FZ_PROCESS_EXCEPTION("1217","分账计算逻辑业务处理报错"),

    PROJECT_REPAYMENTTYPE_INFO_NULL("1218","标的信息中的RepaymentType为空,无法匹配还款计算逻辑类."),
    CALCULATE_INSTALL_NOT_FUND("1219","标的信息中的RepaymentType对应的借款类型(LoanType)不存在."),

    CREATE_REFUND_ORDER_FAIL("1203","还款订单数据入库失败"),
    CREATE_REFUND_ORDER_PROCESS_FAIL("1204","还款订单数据入库业务处理失败"),

    SEND_FREEZE_REQUEST_EXCEPTION("1215","发送资金冻结请求异常"),
    CALL_FREEZE_RESULT_NULL("1205","调用账户中心资金冻结接口成功,但返回TransFreezeResponseDTO=null"),
    CALL_FREEZE_PROCESS_EXCEPTION("1206","调用账户中心资金冻结接口抛出异常"),
    CALL_FREEZE_RESULT_FAIL("1207","冻结业务返回结果失败，修改还款订单行为状态，此时修改记录数=0"),
    CALL_FREEZE_RESULT_FAIL_PROCESS_EXCEPTION("1208","冻结业务返回结果失败，修改还款订单行为状态，此时执行数据处抛出异常"),
    CALL_FREEZE_RESULT_SUCCESS_PROCESS_EXCEPTION("1220","冻结业务返回成功，"),
    CALL_FREEZE_RESULT_SUCCESS_UPDATE_FIAL("1209","冻结成功，订单更新无法找到对应记录"),
    CALL_FREEZE_RESULT_SUCCESS_UPDATE_EXCEPTION("1210","冻结成功，更新订单sql执行异常"),
    CALL_FREEZE_RESULT_SUCCESS_INSERT_DETAIL_ERROR("1211","betail数据插入失败:插入条数与实际条数不符合"),
    CALL_FREEZE_RESULT_SUCCESS_INSERT_DETAIL_BIZ_ERROR("1212","betail.BIZ数据插入失败:插入条数与实际条数不符合"),
    CALL_FREEZE_RESULT_SUCCESS_INSERT_DETAIL_BIZ_EXCEPTION("1213","(RefundOrderService.createDetailAndBiz)betail|biz 数据插入异常:数据执行失败"),
    CALL_FREEZE_RESULT_HANDLE("1215","调用账户中心资金冻结返回处理中,最终状态未明确，终止还款后续业务"),

    USER_ACCOUNT_BALANCE_NOT_ENOUGH("1301","用户账户余额不足"),
    CALL_USER_ACCOUNT_BALANCE_EXCEPTION("1300","调用账户中心获取账户可用余额异常"),

    CALL_CG_EXCEPTION("1400","调用存管问批量交易接口异常:请求可能没发送或者结构没返回"),
    CALL_CG_RESULT_RETURN_NULL("1401","调用存管批量交易结果，return结构为null"),
    CALL_CG_RESULT_CODE_1("1402","调用存管批量交易结果，存管返回结果失败:code=1"),
    CALL_CG_PARAM_BUILD_EXCEPTION("1403","构建存管报文异常"),
    BUILD_CG_PARAM_EXCEPTION("1404","构建存管报文dto对象异常"),

    GET_ORDER_REFUND_TYPE_ENUM_NOT_FUND("9997","枚举检查 ： projectBorrowerSummary.getRepayStatus未定义对应的OrderRefundTypeEnum"),
    PROJECT_IS_FINISH("9998","已经结清，不能发起还款操作"),
    DEFAULT("9999","还款执行未知异常"),
    SUCCESS("0000","操作成功")
    ;

    private String code;
    private String descript;
    RefundProcessMessageEnum(String code,String descript ){
        this.code = code;
        this.descript = descript;
    }

    public String getCode(){return code;}
    public String getDescript(){return descript;}


    public static RefundProcessMessageEnum getRefundProcessMessageEnum(String code){
        for(RefundProcessMessageEnum pp : values()){
            if(pp.code.equals(code)){
                return pp;
            }
        }
        return RefundProcessMessageEnum.DEFAULT;
    }


}
